package user;

import java.io.IOException;
import java.io.PrintWriter;
import java.rmi.server.UID;
import java.util.ArrayList;
import java.util.Iterator;

import javax.net.ssl.SSLSession;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class User_Select_Servlet
 */
@WebServlet("/selectUser")
public class User_Select_Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public User_Select_Servlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//response.getWriter().append("Served at: ").append(request.getContextPath());
	   /*//页面显示中文
		response.setContentType("text/html; charset=UTF-8");
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
	    out.print("谢一弘");*/
		//获取查询条件进行查询，查询完后返回视图进行查询结果的显示
		String uname = request.getParameter("uname");//获取视图上的数据
		//把视图上的数据送到JavaBen执行
		UserDao dao = new UserDao();
		ArrayList<User> list = dao.doSelectByUname(uname);
		HttpSession session = request.getSession();
		session.setAttribute("list", list);
		 response.sendRedirect("/Lesson_310/user/user_select.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}
}
